package com.authine.cloudpivot.web.api.controller;

import com.alibaba.fastjson.JSONObject;
import com.authine.cloudpivot.web.api.controller.base.BaseController;
import com.authine.cloudpivot.web.api.domain.dto.AssessmentStandardDTO;
import com.authine.cloudpivot.web.api.exception.PortalException;
import com.authine.cloudpivot.web.api.service.AssessmentManagementService;
import com.authine.cloudpivot.web.api.service.TimingTaskService;
import com.authine.cloudpivot.web.api.view.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(description = "外企德科相关接口", tags = "考核管理")
@RestController
@RequestMapping("/api/assessmentManagement")
@Slf4j
@Validated
public class AssessmentManagementController extends BaseController {


    @Autowired
    private AssessmentManagementService  assessmentManagementService;

    /**
     * @Description : 根据评分，设置考核标准中的金额
     * @param ：
     * @author : Liun
     * @date : 2020/4/8
     */
    @ApiOperation(value = "根据评分设置金额" )
    @GetMapping ("/selectAmount")
    @ResponseBody
    public ResponseResult<?> selectAmount( String teamName, String role,Integer totalScore){
        JSONObject json = new JSONObject();
        Long statusReal = 200L;
        try {
            AssessmentStandardDTO dto=new AssessmentStandardDTO();
            dto.setTeamName(teamName);
            dto.setRole(role);
            dto.setTotalScore(totalScore);
            int amount= assessmentManagementService.selectAmount(dto);
            json.put("amount",amount);
            json.put("message","获取金额成功");
        } catch (PortalException e) {
            statusReal = 500L;
            json.put("message", "获取金额失败：" + e.getErrMsg());
        }
        return ResponseResult.<JSONObject>builder().errcode(statusReal).data(json).build();

    }


}
